//
//  RegisterServerViewController.m
//  跨界收
//
//  Created by Allen on 2018/10/27.
//  Copyright © 2018年 gztx. All rights reserved.
//

#import "RegisterServerViewController.h"
#import "YKPickerManager.h"

@interface RegisterServerViewController ()<UITextFieldDelegate>

@property (weak, nonatomic) IBOutlet UITextField *phoneTextField;
@property (weak, nonatomic) IBOutlet UITextField *companyTextField;
@property (weak, nonatomic) IBOutlet UITextField *cityTextField;

@property (weak, nonatomic) IBOutlet UIButton *shanghuziyuanBtn;
@property (weak, nonatomic) IBOutlet UIButton *chuangyehezuoBtn;
@property (weak, nonatomic) IBOutlet UIButton *yidongzhifuBtn;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *viewoneConstraint;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *viewTwoContraint;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *viewThreeContraint;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *viewFourConstraint;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *submitYConstairnt;

@end

@implementation RegisterServerViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"申请成为服务商";
    
    self.shanghuziyuanBtn.selected = YES;
    self.cityTextField.delegate = self;
    self.phoneTextField.delegate = self;
    self.companyTextField.delegate = self;
    // Do any additional setup after loading the view from its nib.
}
- (void)viewDidLayoutSubviews {
    [super viewDidLayoutSubviews];
    
    if (SCREEN_WIDTH < 375.0) {
        self.viewoneConstraint.constant = 45;
        self.viewTwoContraint.constant = 45;
        self.viewThreeContraint.constant = 45;
        self.viewFourConstraint.constant = 160;
        self.submitYConstairnt.constant = 40;
    }
}
- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    
    self.navigationController.navigationBarHidden = NO;
}


- (IBAction)click:(UIButton *)sender {
    sender.selected = !sender.selected;
    switch (sender.tag) {
        case 100:
        {
            
            if (sender.selected) {
                self.yidongzhifuBtn.selected = NO;
                self.chuangyehezuoBtn.selected = NO;
            }
        }
            break;
        case 101:
        {
            if (sender.selected) {
                self.shanghuziyuanBtn.selected = NO;
                self.yidongzhifuBtn.selected = NO;
            }
        }
            break;
        case 102:
        {
            if (sender.selected) {
                self.shanghuziyuanBtn.selected = NO;
                self.chuangyehezuoBtn.selected = NO;
            }
        }
            break;
        default:
            break;
    }
    
}

- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField {
    if (textField == self.cityTextField) {
        [[YKPickerManager shareManager] showAddressPickerView:[UIColor redColor] defaultAddress:@"" commitBlock:^(NSString *address, NSString *zipcode) {
            self.cityTextField.text = address;
            NSLog(@"%@",address);
        } cancelBlock:^{
            
        }];
        return NO;
    } else {
        return YES;
    }
}
- (BOOL)textFieldShouldReturn:(UITextField *)textField {
    [self.phoneTextField resignFirstResponder];
    [self.companyTextField resignFirstResponder];
    
    return YES;
}

//// 检查输入框非法输入
//- (BOOL)checkInputContent {
//    BOOL isCorrect = NO;
//    
//    BOOL isCompany = ![Tool isBlankString:self.companyTextField.text];
//    BOOL isCellPhone = [Tool IsPhoneNumber:self.phoneTextField.text];
//    BOOL isVerificationCode = ![Tool isBlankString:self.verificationCodeTextField.text];
//    
//    if (!isInvitationCode) {
//        [self showMBProgressHUDWithWarning:@"请输入邀请码"]; return isCorrect = NO;
//    }
//    
//    if (!isCellPhone) {
//        [self showMBProgressHUDWithWarning:@"请输入正确的手机号"]; return isCorrect = NO;
//    }
//    
//    if (!isVerificationCode) {
//        [self showMBProgressHUDWithWarning:@"请输入验证码"]; return isCorrect = NO;
//    }
//    
//    if (!self.selectAgreementButton.selected) {
//        [self showMBProgressHUDWithWarning:[NSString stringWithFormat:@"请阅读并同意%@协议", appName]]; return isCorrect = NO;
//    }
//    
//    return isCorrect = YES;
//}
- (IBAction)submit:(id)sender {
    
}

@end
